var obj = {
  name: "zhangsan",
  age: 12,
  sayHello: function () { console.log('hello'); }
}
// 将对象转换成JSON格式的对象
console.log(JSON.stringify(obj)); //{"name":"zhangsan","age":12}
// 将json格式的对象转换成对象
console.log(JSON.parse(JSON.stringify(obj)));